
extends Node2D

var score=0
var time=0
var enemys=[preload("res://enemy/enemy1.scn"),preload("res://enemy/enemy2.scn"),preload("res://enemy/enemy3.scn")]
func _ready():
	set_process(true)

	
func _process(delta):
	time+=delta
	var wait=2-time/10
	if wait<.3:
		wait=.3
	else:
		get_node("enemyEmitter").set_wait_time(wait)


		
		
		
		
		
		



func _on_ememyEmitter_timeout():
	var type=0
	var r=rand_range(0,1)
	if r>.7 and time>10:
		type=1
		
	if r>.95 and time>30:
		type=2
		
	
	var ememy=enemys[type].instance()
	get_tree().get_current_scene().add_child(ememy)




func _on_pause_pressed():
	get_tree().set_pause(true)
	get_node("resume").show()
	get_node("bgmusic").set_paused(true)



func _on_resume_pressed():
	get_tree().set_pause(false)
	get_node("resume").hide()
	get_node("bgmusic").set_paused(false)
